<?php
require_once BaseUtil::getModulePath("base")  .  '/forms/BaseForm.php';
require_once BaseUtil::getModulePath("trade")  . '/constants/TradeConstant.php';
require_once BaseUtil::getModulePath("base")  . '/validate/Exist.php';
require_once BaseUtil::getModulePath("base")  . '/validate/LessThan.php';

class AddOfflineSupplementForm extends BaseForm {

	public function __construct(){

		parent::__construct();
		$translate = Zend_Registry::get('Zend_Translate');
		$this->setAction(HttpUtil::getUrl("supplement", "subadd"));

		$parameters = array();

		// trade_num
		$trade_num = new Zend_Form_Element_Text('trade_num');
		$trade_num->addFilter("StringTrim");
		$trade_num->setLabel($translate->_('trade_num'));
		array_push($parameters, $trade_num);

		// user_id
		$user_id = new Zend_Form_Element_Text('user_id');
		$existValid = new Myvalidate_Exist ( );
		$existValid->setTableName ( 'users' );
		$existValid->setFieldName ( 'name' );
		$user_id->addValidator($existValid);
		$user_id->addFilter("StringTrim");
		$user_id->setRequired(true);
		$user_id->setLabel($translate->_('user_id'));
		array_push($parameters, $user_id);

		// trade_sum
		$trade_sum = new Zend_Form_Element_Text('trade_sum');
		$trade_sum->addFilter("StringTrim");
		$trade_sum->setRequired(true);
		$trade_sum->addValidator("float");
		$lessThanValid = new Myvalidate_LessThan(0);
		$trade_sum->addValidator($lessThanValid);
		$trade_sum->setLabel($translate->_('trade_sum'));
		array_push($parameters, $trade_sum);

		// supplement_type
		$supplement_type = new Zend_Form_Element_Select ( "supplement_type" );
		$supplement_type -> setMultiOptions ( TradeConstant::getBankTypeList() );
		$supplement_type -> setRequired ( true );
		$supplement_type->setLabel($translate->_('supplement_type'));
		array_push($parameters, $supplement_type);

		// out_id
		$out_id = new Zend_Form_Element_Text('out_id');
		$out_id->addFilter("StringTrim");
		$out_id->setRequired(true);
		$out_id->setLabel($translate->_('out_id'));
		array_push($parameters, $out_id);

		// out_name
		$out_name = new Zend_Form_Element_Text('out_name');
		$out_name->addFilter("StringTrim");
		$out_name->setRequired(true);
		$out_name->setLabel($translate->_('out_name'));
		array_push($parameters, $out_name);

		// in_id
		$in_id = new Zend_Form_Element_Text('in_id');
		$in_id->addFilter("StringTrim");
		$in_id->setRequired(true);
		$in_id->setLabel($translate->_('in_id'));
		array_push($parameters, $in_id);

		// out_date
		$out_date = new Zend_Form_Element_Text('out_date');
		$out_date->addFilter("StringTrim");
		$out_date->setRequired(true);
		$out_date->setLabel($translate->_('out_date'));
		array_push($parameters, $out_date);

		$this->addElements( $parameters );
		$this->setElementDecorators(array('ViewHelper',array(array('div'=>'HtmlTag'),array('tag'=>'div','class'=>'form_element'))));
	}
}
?>